    //
//  ResultViewController.m
//  BetsAndBrains
//
//  Created by Augustine, Eric M (augus011) on 4/9/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "ResultViewController.h"
#import "BetsAndBrainsViewController.h"
#import "AnswerViewController.h"
#import "Game.h"
#import "Player.h"
#import "Bet.h"
#import "ComputerPlayer.h"
#import "Question.h"

@implementation ResultViewController

@synthesize answerView;
@synthesize betsAndBrainsView;
@synthesize answer;
@synthesize p1;
@synthesize p2;
@synthesize p3;
@synthesize p4;
@synthesize p5;
@synthesize p6;
@synthesize b1;
@synthesize b2;
@synthesize b3;
@synthesize b4;
@synthesize b5;
@synthesize b6;
@synthesize game;

-(IBAction)mainMenu{
	[self presentModalViewController:betsAndBrainsView animated: TRUE];
}

-(IBAction)nextRound{
	[game clearBets];
	[game clearGuesses];
	answerView.game = self.game;
	[self presentModalViewController:answerView animated: TRUE];
}

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	[self.answer setText:[NSString stringWithFormat:@"%d", game.currentQuestion.answer]];
	[self.p1 setText:[[self.game.players objectAtIndex:0] playerName]];
	[self.p2 setText:[[self.game.players objectAtIndex:1] playerName]];
	[self.p3 setText:[[self.game.players objectAtIndex:2] playerName]];
	[self.p4 setText:[[self.game.players objectAtIndex:3] playerName]];
	[self.p5 setText:[[self.game.players objectAtIndex:4] playerName]];
	[self.p6 setText:[[self.game.players objectAtIndex:5] playerName]];
	[self.b1 setText:[NSString stringWithFormat:@"%d", [[self.game.players objectAtIndex:0] permChips] + [[self.game.players objectAtIndex:0] gameChips]]];
	[self.b2 setText:[NSString stringWithFormat:@"%d", [[self.game.players objectAtIndex:1] permChips] + [[self.game.players objectAtIndex:1] gameChips]]];
	[self.b3 setText:[NSString stringWithFormat:@"%d", [[self.game.players objectAtIndex:2] permChips] + [[self.game.players objectAtIndex:2] gameChips]]];
	[self.b4 setText:[NSString stringWithFormat:@"%d", [[self.game.players objectAtIndex:3] permChips] + [[self.game.players objectAtIndex:3] gameChips]]];
	[self.b5 setText:[NSString stringWithFormat:@"%d", [[self.game.players objectAtIndex:4] permChips] + [[self.game.players objectAtIndex:4] gameChips]]];
	[self.b6 setText:[NSString stringWithFormat:@"%d", [[self.game.players objectAtIndex:5] permChips] + [[self.game.players objectAtIndex:5] gameChips]]];
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
	
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
	self.answerView = nil;
	self.betsAndBrainsView = nil;
	self.answer = nil;
	self.p1 = nil;
	self.p2 = nil;
	self.p3 = nil;
	self.p4 = nil;
	self.p5 = nil;
	self.p6 = nil;
	self.b1 = nil;
	self.b2 = nil;
	self.b3 = nil;
	self.b4 = nil;
	self.b5 = nil;
	self.b6 = nil;
	self.game = nil;
}


- (void)dealloc {
    [super dealloc];
	[answerView autorelease];
	[betsAndBrainsView autorelease];
	[answer autorelease];
	[p1 autorelease];
	[p2 autorelease];
	[p3 autorelease];
	[p4 autorelease];
	[p5 autorelease];
	[p6 autorelease];
	[b1 autorelease];
	[b2 autorelease];
	[b3 autorelease];
	[b4 autorelease];
	[b5 autorelease];
	[b6 autorelease];
	[game autorelease];
}


@end
